//
//  DisAllBannerColCell.swift
//  WalkNovel
//
//  Created by Kevin on 2023/9/1.
//

import UIKit

class DisAllBannerColCell: UICollectionViewCell, WNCycleViewProtocol {
    
    lazy var bannerView: WNCycleView = {
        let view = WNCycleView()
        view.delegate = self
        return view
    }()
    
    var bannerArr: [BookDetailModel]? {
        didSet {
            bannerView.setBookArr(bannerArr)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .white
        addSubview(bannerView)
        bannerView.snp.makeConstraints { (make) in
            make.top.left.equalTo(12)
            make.bottom.right.equalTo(-12)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func wncycleViewDidSelectedIndex(_ index: Int) {
        viewContainingController?.wn_pushBookVC(bannerArr?[index].bookId ?? "")
    }
}
